using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace DataStructure
{
    public class Array2Queue<T> : IQueue<T>
    {
        private Array2<T> arr;
        
        public Array2Queue(int capacity)
        {
            arr = new Array2<T>(capacity);
        }
        
        public Array2Queue()
        {
            arr = new Array2<T>();
        }
        public int Count => arr.Count;

        public bool IsEmpty => arr.IsEmpty;
        
        //入队,往队尾添加元素O(1)
        public void Enqueue(T data)
        {
            arr.AddLast(data);
        }

        //出队，删除队首的元素O(1)
        public T Dequeue()
        {
            return arr.RemoveFirst();
        }

        //查看队首元素O(1)
        public T Peek()
        {
            return arr.GetFirst();
        }
        public override string ToString()
        {
            return "Queue: front" + arr.ToString() + "Tail";
        }
    }
}